import { TEquipShenglingConfig } from "../../../Message/Db/Tables/TEquipShenglingConfig";
import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
import { TEquipShenglingLevel } from "../../../Message/Db/Tables/TEquipShenglingLevel";
import { TWuxingConfig } from "../../../Message/Db/Tables/TWuxingConfig";
import { StringHelper } from "../../../com/gengine/utils/StringHelper";
type int = number;
//class WuXingConfig
    
    export  class WuXingConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            this._typeMap = new Map<any, any> /* flash.utils.Dictionary */();
            this._wuxingShenglingMap = new Map<any, any> /* flash.utils.Dictionary */();
            this.wuxingShenglingLvMap = new Map<any, any> /* flash.utils.Dictionary */();
            this.maxLvArr = [];
            if (WuXingConfig._instance) 
            {
                throw new Error("WuXingConfig is single");
            }
            this.init();
            return;
        }

        public getWXSkillNeedFightValue(arg1: int): int
        {
            var loc1=null;
            var loc2=0;
            var loc3=this._typeMap[WuXingConfig.SkillTypeConfig];
            for(loc1 of loc3) 
            {
                if (loc1.intExtend2 != arg1) 
                {
                    continue;
                }
                return loc1.value;
            }
            return 0;
        }

        public getWuxingSpiritTarget(arg1: int): int
        {
            var loc1=null;
            var loc2=0;
            var loc3=this._typeMap[WuXingConfig.WuxingSpiritTarget];
            for(loc1 of loc3) 
            {
                if (loc1.color != arg1) 
                {
                    continue;
                }
                return loc1.value;
            }
            return 0;
        }

        public getMaxShenglingLevel(arg1: int): int
        {
            return this.wuxingShenglingLvMap[arg1];
        }

        public getShengLingDetailInfo(arg1: int): TEquipShenglingConfig
        {
            return this._wuxingShenglingMap[arg1];
        }

        public static get instance(): WuXingConfig
        {
            if (!WuXingConfig._instance) 
            {
                WuXingConfig._instance = new WuXingConfig();
            }
            return WuXingConfig._instance;
        }

        /* internal  */init(): void
        {
            this._typeMap[WuXingConfig.SpiritExpConfig] = new Map<any, any> /* flash.utils.Dictionary */();
            this._typeMap[WuXingConfig.SpiritUpgradeConfig] = new Map<any, any> /* flash.utils.Dictionary */();
            this._typeMap[WuXingConfig.SpiritBaseValueConfig] = new Map<any, any> /* flash.utils.Dictionary */();
            this._typeMap[WuXingConfig.EnergyAddExpConfig] = new Map<any, any> /* flash.utils.Dictionary */();
            this._typeMap[WuXingConfig.Attribute1RateConfigl] = new Map<any, any> /* flash.utils.Dictionary */();
            this._typeMap[WuXingConfig.SkillTypeConfig] = new Map<any, any> /* flash.utils.Dictionary */();
            this._typeMap[WuXingConfig.WuxingEnergyConfig] = new Map<any, any> /* flash.utils.Dictionary */();
            this._typeMap[WuXingConfig.AttributeRateControl] = new Map<any, any> /* flash.utils.Dictionary */();
            this._typeMap[WuXingConfig.ChangeEnergyConfig] = new Map<any, any> /* flash.utils.Dictionary */();
            this._typeMap[WuXingConfig.WuxingEnergyEtc] = new Map<any, any> /* flash.utils.Dictionary */();
            this._typeMap[WuXingConfig.WuxingSpiritTarget] = new Map<any, any> /* flash.utils.Dictionary */();
            this.write(ConfigManager.instance.getJSONByFileName("t_wuxing_config.json"));
            this.writeShengLing(ConfigManager.instance.getJSONByFileName("t_equip_shengling_config.json"));
            this.writeShengLingLv(ConfigManager.instance.getJSONByFileName("t_equip_shengling_level.json"));
            return;
        }

        /* internal  */writeShengLing(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1;
            for(loc2 of loc4) 
            {
                loc1 = new TEquipShenglingConfig();
                loc1.level = loc2.level;
                loc1.materialCode = loc2.materialCode;
                loc1.materailNum = loc2.materailNum;
                loc1.money = loc2.money;
                loc1.successRate = loc2.successRate;
                loc1.addPerLevel = loc2.addPerLevel;
                loc1.addTotal = loc2.addTotal;
                loc1.ignoreRelief = loc2.ignoreRelief;
                this._wuxingShenglingMap[loc1.level] = loc1;
            }
            return;
        }

        /* internal  */writeShengLingLv(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1;
            for(loc2 of loc4) 
            {
                loc1 = new TEquipShenglingLevel();
                loc1.equipLevel = loc2.equipLevel;
                loc1.maxShenglingLevel = loc2.maxShenglingLevel;
                this.wuxingShenglingLvMap[loc1.equipLevel] = loc1.maxShenglingLevel;
                this.maxLvArr.push(loc1.equipLevel);
            }
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1;
            for(loc2 of loc4) 
            {
                loc1 = new TWuxingConfig();
                loc1.color = loc2.color;
                loc1.des = StringHelper.getString(loc2.des);
                loc1.id = loc2.id;
                loc1.level = loc2.level;
                loc1.type = loc2.type;
                loc1.value = loc2.value;
                loc1.num = loc2.num;
                loc1.rate = loc2.rate;
                loc1.intExtend1 = loc2.intExtend1;
                loc1.intExtend2 = loc2.intExtend2;
                loc1.intExtend3 = loc2.intExtend3;
                this._map[loc1.id] = loc1;
                if (!this._typeMap.hasOwnProperty(loc1.type)) 
                {
                    continue;
                }
                this._typeMap[loc1.type][loc1.id] = loc1;
            }
            return;
        }

        public getTWXById(arg1: int): TWuxingConfig
        {
            return this._map[arg1];
        }

        public getUpgradeUpValue(arg1: int): int
        {
            var loc1=null;
            var loc2=0;
            var loc3=this._typeMap[WuXingConfig.SpiritUpgradeConfig];
            for(loc1 of loc3) 
            {
                if (loc1.color != arg1) 
                {
                    continue;
                }
                return loc1.intExtend2;
            }
            return 0;
        }

        public getLevelExpValue(arg1: int, arg2: int): int
        {
            var loc1=null;
            var loc2=0;
            var loc3=this._typeMap[WuXingConfig.SpiritExpConfig];
            for(loc1 of loc3) 
            {
                if (!(loc1.color == arg1 && loc1.level == arg2)) 
                {
                    continue;
                }
                return loc1.value;
            }
            return 0;
        }

        public getChangeEnergyCost(arg1: int): int
        {
            var loc2=null;
            var loc1=this.getMaxChangeEnergyNum();
            if (arg1 >= loc1) 
            {
                arg1 = loc1;
            }
            var loc3=0;
            var loc4=this._typeMap[WuXingConfig.ChangeEnergyConfig];
            for(loc2 of loc4) 
            {
                if (loc2.num != arg1) 
                {
                    continue;
                }
                return loc2.value;
            }
            return 0;
        }

        /* internal  */getMaxChangeEnergyNum(): int
        {
            var loc1=0;
            var loc2=null;
            var loc3=0;
            var loc4=this._typeMap[WuXingConfig.ChangeEnergyConfig];
            for(loc2 of loc4) 
            {
                if (!(loc2.num >= loc1)) 
                {
                    continue;
                }
                loc1 = loc2.num;
            }
            return loc1;
        }

        public getWuxingEnergy(arg1: int): int
        {
            var loc1=null;
            var loc2=0;
            var loc3=this._typeMap[WuXingConfig.WuxingEnergyConfig];
            for(loc1 of loc3) 
            {
                if (loc1.num != arg1) 
                {
                    continue;
                }
                return loc1.value;
            }
            return 0;
        }

        public getWuxingEnergyEtc(arg1: int): int
        {
            var loc1=null;
            var loc2=0;
            var loc3=this._typeMap[WuXingConfig.WuxingEnergyEtc];
            for(loc1 of loc3) 
            {
                if (loc1.num != arg1) 
                {
                    continue;
                }
                return loc1.value;
            }
            return 0;
        }

        public getValueByColorAndLevel(arg1: int, arg2: int): int
        {
            var loc1=null;
            var loc2=0;
            var loc3=this._typeMap[WuXingConfig.SpiritBaseValueConfig];
            for(loc1 of loc3) 
            {
                if (!(loc1.color == arg1 && loc1.level == arg2)) 
                {
                    continue;
                }
                return loc1.value;
            }
            return 0;
        }

        public getBaseSkillId(arg1: int): int
        {
            var loc1=null;
            var loc2=0;
            var loc3=this._typeMap[WuXingConfig.SkillTypeConfig];
            for(loc1 of loc3) 
            {
                if (!(loc1.intExtend1 == arg1 && loc1.level == 1)) 
                {
                    continue;
                }
                return loc1.intExtend2;
            }
            return 0;
        }

        public getBaseJuhunValue(): int
        {
            var loc1=null;
            var loc2=0;
            var loc3=this._typeMap[WuXingConfig.EnergyAddExpConfig];
            for(loc1 of loc3) 
            {
                return loc1.value;
            }
            return 0;
        }

        public getColorChangeMoneyCost(arg1: int): int
        {
            var loc1=null;
            var loc2=0;
            var loc3=this._typeMap[WuXingConfig.SpiritUpgradeConfig];
            for(loc1 of loc3) 
            {
                if (loc1.color != arg1) 
                {
                    continue;
                }
                return loc1.num;
            }
            return 0;
        }

        public getColorChangeItemCost(arg1: int): int
        {
            var loc1=null;
            var loc2=0;
            var loc3=this._typeMap[WuXingConfig.SpiritUpgradeConfig];
            for(loc1 of loc3) 
            {
                if (loc1.color != arg1) 
                {
                    continue;
                }
                return loc1.value;
            }
            return 0;
        }

        public getWXSkillByAttr(arg1: int, arg2: int): int
        {
            var loc1=null;
            var loc2=0;
            var loc3=this._typeMap[WuXingConfig.SkillTypeConfig];
            for(loc1 of loc3) 
            {
                if (!(loc1.intExtend1 == arg1 && loc1.level == arg2)) 
                {
                    continue;
                }
                return loc1.intExtend2;
            }
            return 0;
        }

        public static /* const */SpiritUpgradeConfig: string="WuXingConfig.SpiritUpgradeConfig";

        public static /* const */SpiritBaseValueConfig: string="WuXingConfig.SpiritBaseValueConfig";

        public static /* const */EnergyAddExpConfig: string="WuXingConfig.EnergyAddExpConfig";

        public static /* const */Attribute1RateConfigl: string="WuXingConfig.Attribute1RateConfigl";

        public static /* const */SkillTypeConfig: string="WuXingConfig.SkillTypeConfig";

        public static /* const */WuxingEnergyConfig: string="WuXingConfig.WuxingEnergyConfig";

        public static /* const */AttributeRateControl: string="WuXingConfig.AttributeRateControl";

        public static /* const */ChangeEnergyConfig: string="WuXingConfig.ChangeEnergyConfig";

        public static /* const */WuxingEnergyEtc: string="WuXingConfig.WuxingEnergyEtc";

        public static /* const */WuxingSpiritTarget: string="WuXingConfig.WuxingSpiritTarget";

        public static /* const */SpiritExpConfig: string="WuXingConfig.SpiritExpConfig";

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_typeMap: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_wuxingShenglingMap: Map<any, any> /* flash.utils.Dictionary */;

        public /* var */wuxingShenglingLvMap: Map<any, any> /* flash.utils.Dictionary */;

        public /* var */maxLvArr: Array<any>;

        /* internal */ static /* var */_instance: WuXingConfig;
    }
